﻿#region (C) Header Region @ 2012
//====================================================
// 文件: jQueryUtilityCache.cs
// 描述: ajax缓存类
// 路径: Antu.Core\Ajax\jQueryUtilityCache.cs
// ******************版本1 ******************
// 人员: 蔡金保    时间 : 2012/11/15 11:24:32
// 注释:该类为了提高反射调用的效能
//====================================================
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace Antu.Core.Ajax
{
    public class UtilityCache
    {
        private Dictionary<Type, string> dict = new Dictionary<Type, string>();

        private static readonly UtilityCache _jQueryUtilityCache = new UtilityCache();

        public static UtilityCache Current
        {
            get
            {
                return _jQueryUtilityCache;
            }
        }

        public void AddScript(Type type, string script)
        {
            if (dict.ContainsKey(type))
            {
                dict[type] = script;
            }
            else
            {
                dict.Add(type, script);
            }
        }

        public string GetScript(Type type)
        {
            if (dict.ContainsKey(type))
            {
                return dict[type];
            }
            return string.Empty;
        }

        public bool Exists(Type type)
        {
            return dict.ContainsKey(type);
        }
    }
}
